<?php

/**
 * 优惠券
 * Class VoucherController
 */
class VoucherController extends BaseController
{
    use \app\library\traits\Restful;

    public function init(){
        parent::init();
        $this->checkLogin();
    }

    public function read()
    {
        $list = (new VoucherTemplateModel())->getAllVaild();

        return $this->returnSuccess($list);
    }

    /**
     * 获取我当前可使用优惠券的数量
     */
    public function myVoucherNumAction()
    {
       $num = (new VoucherBaseModel())->countVaildByUser($this->user_id);
       return $this->returnSuccess(['count'=>$num]);
    }
}
